package main

import "fmt"

// 封装
type Dog struct {
	name string
	age  int
}

// 方法定义
func (dog Dog) eat() {
	fmt.Println("DOG, eating")
}

func (dog Dog) sleep() {
	fmt.Println("DOG, sleeping")
}

type Cat struct {
	name string
	age  int
}

func (cat Cat) eat() {
	fmt.Println("Cat, eating")
}

func main() {
	dog := Dog{"dog1", 11}
	dog.eat()
	dog.sleep()
	cat := Cat{"cat1", 22}
	cat.eat()
}
